<?php

//UMA new
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class NikkeiScoreRate extends Model
{
    protected $fillable = [
        'min_change',
        'max_change',
        'rate',
    ];

    /**
     * query scope
     *
     * @param builder $query
     * @param integer $value
     * @return query
     */
    public function scopeLessThanValue($query, $value)
    {
        if ($value < 0) {
            return $query->where('min_change', '<=', $value)->orderBy('min_change', 'desc');
        }
        return $query->where('min_change', '<', $value)->orderBy('min_change', 'desc');
    }
}
